package t.com.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.List;

import t.com.adapter.DollsAdapter;
import t.com.base.BaseActivity;
import t.com.bean.NewsBean;
import t.com.presenter.INewsPresenter;
import t.com.view.INewsView;

public class MainActivity extends BaseActivity<INewsView,INewsPresenter> implements INewsView {

    private RecyclerView dollsRecycler;
    private DollsAdapter adapter;


    @Override
    protected void onCreateView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_main);
    }

    @Override
    protected void initView() {
        super.initView();
        dollsRecycler = (RecyclerView) findViewById(R.id.dollsRecycler);
//        LinearLayoutManager manager = new LinearLayoutManager(this);
//        manager.setOrientation(LinearLayoutManager.VERTICAL);
        dollsRecycler.setLayoutManager(new LinearLayoutManager(this));
    }

    @Override
    protected void initData() {
        super.initData();
        adapter = new DollsAdapter(R.layout.dolls_item);
        dollsRecycler.setAdapter(adapter);
        getBasePresenter().showGiveDolls();
    }

    @Override
    protected INewsPresenter setPresenter() {
        return new INewsPresenter();
    }

    @Override
    public void showData(final List<NewsBean> beanList) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                adapter.addData(beanList);
                adapter.notifyDataSetChanged();
            }
        });
    }
}
